import { post, get } from '../request.js'

/**
 * 登录
 * @param {*} params
 * @returns
 */
export const login = params => {
    return post({
        url: '/login',
        params,
        headers: {
            isToken: false,
            contentType: 'application/json'
        }
    })
}

/**
 * 退出登录
 * @returns
 */
export const logout = () => {
    return get({
        url: '/logout'
    })
}

/**
 * 获取验证码
 * @returns
 */
export const getCodeImg = params => {
    return get({
        url: '/captcha',
        params,
        headers: {
            isToken: false,
            contentType: 'application/json'
        }
    })
}

/**
 * 获取用户详细信息
 * @returns
 */
export const getInfo = () => {
    return get({
        url: '/user/info',
        headers: {
            isToken: true,
            contentType: 'application/json'
        }
    })
}

/**
 * 获取路由菜单
 * @param {*} params
 * @returns
 */
export const getRouters = params => {
    return get({
        url: '/system/menu/getRouters',
        params
    })
}

/**
 * 注册
 * @param {*} params
 * @returns
 */
export const register = params => {
    return post({
        url: '/users/register',
        params,
        headers: {
            contentType: 'application/json'
        }
    })
}
